package com.genexususa.eo.bing.data.wsSubclasses;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.IncrementalBidPercentage;
import com.genexususa.eo.bing.CampaignManagementServiceClasses.RadiusTargetBid;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class GxRadiusTargetBid extends RadiusTargetBid {
    public GxRadiusTargetBid(Element element) {
        if (element.getElementsByTagName("BidAdjustment").getLength() > 0 &&
                element.getElementsByTagName("BidAdjustment").item(0).getChildNodes().getLength() > 0) {
            //this.setIncrementalBid(IncrementalBidPercentage.fromString(element.getElementsByTagName("IncrementalBid").item(0).getChildNodes().item(0).getNodeValue()));
            this.setBidAdjustment(Integer.parseInt(element.getElementsByTagName("BidAdjustment").item(0).getChildNodes().item(0).getNodeValue()));
        }
        if (element.getElementsByTagName("RadiusTargetBidId").getLength() > 0 &&
            element.getElementsByTagName("RadiusTargetBidId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("RadiusTargetBidId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.setId(Long.valueOf(((Node) element.getElementsByTagName("RadiusTargetBidId").item(0).getChildNodes().item(0)).getNodeValue()));
        }
        if (element.getElementsByTagName("IsExcluded").getLength() > 0 &&
            element.getElementsByTagName("IsExcluded").item(0).getChildNodes().getLength() > 0) {
            //this.setIncrementalBid(IncrementalBidPercentage.fromString(element.getElementsByTagName("IncrementalBid").item(0).getChildNodes().item(0).getNodeValue()));
            this.setIsExcluded(Boolean.parseBoolean(element.getElementsByTagName("IsExcluded").item(0).getChildNodes().item(0).getNodeValue()));
        }
        if (element.getElementsByTagName("LatitudeDegrees").getLength() > 0 &&
            element.getElementsByTagName("LatitudeDegrees").item(0).getChildNodes().getLength() > 0) {
            this.setLatitudeDegrees(Double.valueOf(element.getElementsByTagName("LatitudeDegrees").item(0).getChildNodes().item(0).getNodeValue()));
        }
        if (element.getElementsByTagName("LongitudeDegrees").getLength() > 0 &&
            element.getElementsByTagName("LongitudeDegrees").item(0).getChildNodes().getLength() > 0) {
            this.setLongitudeDegrees(Double.valueOf(element.getElementsByTagName("LongitudeDegrees").item(0).getChildNodes().item(0).getNodeValue()));
        }
        if (element.getElementsByTagName("Name").getLength() > 0 &&
            element.getElementsByTagName("Name").item(0).getChildNodes().getLength() > 0) {
            this.setName(element.getElementsByTagName("Name").item(0).getChildNodes().item(0).getNodeValue());
        }
        if (element.getElementsByTagName("Radius").getLength() > 0 &&
            element.getElementsByTagName("Radius").item(0).getChildNodes().getLength() > 0) {
            this.setRadius(Integer.valueOf(element.getElementsByTagName("Radius").item(0).getChildNodes().item(0).getNodeValue()));
        }
    }
}
